var _Scene = require('component/scene.js');
var _layout = require('tools/layout.js');
var _relative = _layout.relative;
var _inherit = require('core/inherit.js');
var _MapConf = require('scenes/game/mapconf.js');
var _MapBg = require('scenes/game/mapbg.js');
var _levels = require('scenes/game/config.js');
var _global = require('game/global.js');
var R = require('game/texture.js').R;
var _Progress = require('scenes/widget/roundprogress.js');
var _TouchNode = require('component/touchnode.js').TouchNode;
var _StyleText = require('drawable/styletext.js');
var S = require('game/style.js');

var _GrowthPanel = require('scenes/game/growth.js');

/**
 * scale wrapper
 * @type {*}
 */
var Scene = _Scene.createScene(
    function (w, h) {
        this.onSizeChange(w, h);
        var data = _levels.level_1;
        this.mMapConfig = new _MapConf(data);
        this.mMapBg = new _MapBg(this.mMapConfig);
        this.mMapBg.setPosition(40, 40);
        this.mMapBg.setScale(0.7);
        this.addChild(this.mMapBg);
        this.mProgressF = 0;

        this.addChild(this.mCount1 = new _GrowthPanel({
            collect: [
                {name: '', count: ''}
            ]
        }));
        this.addChild(this.mCount2 = new _GrowthPanel({
            collect: [
                {name: '', count: ''},
                {name: '', count: ''}
            ]
        }));
        this.addChild(this.mCount3 = new _GrowthPanel({
            collect: [
                {name: '', count: ''},
                {name: '', count: ''},
                {name: '', count: ''}
            ]
        }));
        this.addChild(this.mCount4 = new _GrowthPanel({
            collect: [
                {name: '', count: ''},
                {name: '', count: ''},
                {name: '', count: ''},
                {name: '', count: ''}
            ]
        }));
        for (var i = 0; i < 4; i++) {
            this['mCount' + (i + 1)].setPosition(200 * i, 0);
        }

        var x = 2;
        var y = 2;
        var text = S.cover.complete.createText('Completed!');
        text.setPosition(x, y);
        this.addChild(text);

    }
);
Scene.prototype.createEventNode = function () {
    return new _TouchNode(this);
};
Scene.prototype.onTouch = function (event) {
    this.mProgressF = 0;
};
Scene.prototype.update = function (context) {
    if (this.mProgressF < 1) {
        this.mProgressF += context.stride() * 0.1;
        //this.mProgress.setPercent(this.mProgressF);
    }
};
Scene.prototype.onSizeChange = function (w, h) {
    this.setSize(w, h);
};

module.exports = Scene;